<style lang="scss" scoped>
  .redItem .el-form-item__label {
    color: beige;
  }

  .el-table::before {
    z-index: inherit;
  }

  .app-main {
    min-height: calc(100vh - 50px);
    width: 100%;
    position: relative;
    overflow: hidden;
    background-color: #44484a;
  }
</style>
<template>
  <div class="app-container" style="background-color: #44484a;min-height: calc(100vh - 84px);">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"
             style="width: 50%; position: absolute;margin: 0 0 0 0;z-index: 3;">
      <el-form-item label="标题" prop="content" class="redItem">
        <el-input
          v-model="queryParams.content"
          placeholder="请输入标题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <pagination
      v-show="total>0"
      :total="total"
      :style="{background:'#44484a',padding: '0px 0px 0px 0px !important',margin: '4px 0px 0px 0px',color:'red'}"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      style="z-index: 2"
      @pagination="getList"
    />
    <el-table
      v-loading="loading"
      :border="false"
      :header-cell-style="{ background: '#44484a',color:'#c2c2c2',border:'none'}"
      :cell-style="{ background: '#44484a',color:'#c2c2c2' ,border:'none',padding: '0'}"
      style="font-size: 18px;background-color:#44484a"
      :data="infoList">
      <el-table-column prop="title" align="left" label="">
        <!--<template slot-scope="infoList">
          <a :href="infoList.row.url"
             target="_parent"
             class="TestCSS">{{infoList.row.title}}
          </a>
        </template>-->
        <template slot-scope="scope">
          <div @click='showContents(scope.row.remark,scope.row.url)'>
            <span style="color: #5f9ea0">{{scope.row.title}}</span>--->{{scope.row.content}}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" width="50%" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            :style="{color:'rgba(254,254,85,0.62)'}"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['my:info:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="70%" style="height: 80%">
      <iframe
        :src="mastUrl"
        frameborder="no"
        style="width: 100%; height: -webkit-fill-available"
      />
    </el-dialog>
  </div>
</template>
<script>
  import {delInfo, listInfo} from "@/api/my/info";

  export default {
    name: "Info",
    data() {
      return {
        showHeader: false,
        // 遮罩层
        loading: true,
        //网页
        mastUrl: "https://www.baidu.com/",
        // 选中数组
        ids: [],
        // 非单个禁用
        single: false,
        // 非多个禁用
        multiple: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 线报表格数据
        infoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          title: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        timer: ''
      };
    },
    created() {
      this.getList();
    },
    beforeDestroy() {
      clearInterval(this.timer);
    },
    mounted() {
      this.timer = setInterval(this.getList, 60000);
    },
    methods: {
      /** 查询线报列表 */
      getList() {
        this.loading = true;
        listInfo(this.queryParams).then(response => {
          this.infoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          url: null,
          title: null,
          content: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null
        };
        this.resetForm("form");
      },
      showContents(head, url) {
        this.open = true;
        this.mastUrl = head + url + "#postlist";
        this.title = "详情";
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        if (delInfo(ids)) {
          this.$modal.msgSuccess("删除成功");
          this.getList();
        }
      }
    }
  };
</script>
